package com.lanou3g.code0512.homework;

import org.apache.commons.io.IOUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;

/**
 * If there are no bugs, it was created by Chen FengYao on 2018/5/12;
 * Otherwise, I don't know who created it either
 */

@WebServlet(name = "BServlet",urlPatterns = "/b")
public class BServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        response.setCharacterEncoding("utf8");
        response.getWriter().println("我");

//        response.setCharacterEncoding("utf8");
//
//        String filename = "作业.zip";
//        // 把汉字转换成 url编码
//        filename = URLEncoder.encode(filename,"utf8");
//
//
//        response.setHeader("Content-Disposition",
//                "attachment;filename="+filename);
//
//
//        InputStream is = getServletContext()
//                .getResourceAsStream("file/aa.zip");
//        response.getOutputStream().write(IOUtils.toByteArray(is));
    }
}
